/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package com.eng.scc.core.schema.fetcher;

import com.eng.scc.core.data.HomeState;
import com.eng.scc.core.db.Database;
import com.eng.scc.core.db.Fetcher;
import java.sql.PreparedStatement;
import java.sql.ResultSet;

/**
 *
 * @author Rafael
 */
public class HomeStateFetcher implements Fetcher<HomeState>
{

    @Override
    public HomeState fetch( ResultSet ps ) throws Exception
    {
        HomeState hs = new HomeState();
        
        hs.setId( ps.getInt( 1 ) );
        hs.setName( ps.getString( 2 ) );
        
        return hs;
    }

    @Override
    public void insert( HomeState value, PreparedStatement ps ) throws Exception
    {
        value.setId( Database.getInstance().nextID( "core_home_states" ) );
        
        ps.setInt( 1, value.getId() );
        ps.setString( 2, value.getName() );
    }

    @Override
    public void update( HomeState value, PreparedStatement ps ) throws Exception
    {
        ps.setString( 1, value.getName() );
        ps.setInt( 2, value.getId() );
    }
    
}
